package com.carleasoft.mps.cms.business.article.service.Impl;

import com.aspose.slides.internal.mw.aaa;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.carleasoft.mps.cms.business.article.bean.entity.ArticleDataEntity;
import com.carleasoft.mps.cms.business.article.dao.ArticleDataDao;
import com.carleasoft.mps.cms.business.article.service.ArticleDataService;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import java.util.List;

@Service
public class ArticleDataServiceImpl implements ArticleDataService {

    @Autowired
    private ArticleDataDao articleDataDao;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertArticleData(ArticleDataEntity articleDataEntity) {

        return articleDataDao.insert(articleDataEntity);
    }

    @Override
    public ArticleDataEntity selectOne(String articleCode) {
        ArticleDataEntity articleDataEntity = new ArticleDataEntity();
        articleDataEntity.setArticleCode(articleCode);
        QueryWrapper<ArticleDataEntity> articleDataEntityQueryWrapper = new QueryWrapper<>(articleDataEntity);
        return articleDataDao.selectOne(articleDataEntityQueryWrapper);
    }

    @Override
    public int updateByCode(ArticleDataEntity articleDataEntity) {
        return articleDataDao.updateById(articleDataEntity);
    }

    @Override
    public List<ArticleDataEntity> findByList(List<String> categoryList) {
        LambdaQueryWrapper<ArticleDataEntity> wrapper = Wrappers.lambdaQuery();
        wrapper.in(ArticleDataEntity::getArticleCode, categoryList);
        return articleDataDao.selectList(wrapper);
    }


}
